#!/bin/bash
echo 开始拉取最新代码!
cd /home/app/yc-sole
git checkout v2.0.0
git pull
echo 开始打包 远昌管家 前端程序!
cd /home/app/yc-sole/yc-sole-admin-web
npm install
npm run build:prod
echo 远昌管家 前端程序 打包成功!

echo 开始打包 远昌管家 手机端程序!
cd /home/app/yc-sole/yc-sole-vant
npm install
npm run build
echo 远昌管家 手机端程序 打包成功!

echo 重启nginx
NGINX_PATH=/usr/local/nginx/sbin/nginx

# 检查当前用户是否具有执行权限
if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

# 检查 Nginx 是否在运行
if pgrep nginx > /dev/null; then
    echo "Nginx is running, restarting..."
    $NGINX_PATH -s reload
else
    echo "Nginx is not running, starting..."
    $NGINX_PATH
fi
echo nginx重启完成

echo 开始打包 远昌管家 后台程序
cd /home/app/yc-sole/yc-sole
mvn clean install

sh /home/app/restart.sh
